package com.lxblyw.util;

import java.io.File;
import java.io.IOException;


import com.google.zxing.BarcodeFormat;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;

public class EncodeUtil {
	public static void createEncode(String str,String path) {
	
		BitMatrix byteMatrix;
		try {
			byteMatrix = new MultiFormatWriter().encode(str,BarcodeFormat.QR_CODE, 200, 200);

			File file = new File(path + ".png"); 
			MatrixToImageWriter.writeToFile(byteMatrix, "png", file);
		} catch (IOException e) {
			e.printStackTrace();
		} catch (WriterException e1) {
			e1.printStackTrace();
		}
	}
	
	
}
